package com.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.entity.MvType;
import com.service.MvTypeService;

@RequestMapping("/mvType")
@Controller
public class MvTypeController {

	@Autowired
	private MvTypeService mvTypeService;
	
	@RequestMapping("/mvType_show")
	public String mvType_show(Model model) {
		List<Map<String, Object>> mvTypeList = mvTypeService.queryMvType();
		model.addAttribute("mvTypeList", mvTypeList);
		return "admin/mvType";
	}
	
	@RequestMapping("/mvType_add_show")
	public String mvType_add_show() {
		return "admin/mvType-add";
	}
	
	@RequestMapping("/mvType_add_submit")
	public String mvType_add_submit(MvType mvType) {
		mvTypeService.addMvType(mvType);
		return "admin/mvType-add";
	}
	
	@RequestMapping("/mvType_update_show")
	public String mvType_update_show(Integer mvTypeId,Model model) {
		Map<String, Object> mvTypeMap = mvTypeService.queryMusicTypeId(mvTypeId);
		model.addAttribute("mvTypeMap", mvTypeMap);
		return "admin/mvType-edit";
	}
	
	@RequestMapping("/mvType_update_submit")
	public String mvType_update_submit(MvType mvType) {
		mvTypeService.editMvType(mvType);
		return "admin/mvType-edit";
	}
	
	@RequestMapping("/mvType_delete")
	public String mvType_delete(Integer mvTypeId) {
		mvTypeService.delMvType(mvTypeId);
		return "admin/mvType";
	}
}
